extension MyIntExtension on int {
  String toHexString({int fixedLength = 2}) {
    return toRadixString(16).padLeft(fixedLength, "0").toUpperCase();
  }

  String toFileSize({int fractionDigits = 0}) {
    if (this >= 1000000000000) {
      return "${(this / 1000000000000).toStringAsFixed(fractionDigits)}TB";
    } else if (this >= 1000000000) {
      return "${(this / 1000000000).toStringAsFixed(fractionDigits)}GB";
    } else if (this >= 1000000) {
      return "${(this / 1000000).toStringAsFixed(fractionDigits)}MB";
    } else if (this >= 1000) {
      return "${(this / 1000).toStringAsFixed(fractionDigits)}KB";
    }
    return "${this}B";
  }

  String toFileSize1024({int fractionDigits = 0}) {
    if (this >= 1099511627776) {
      return "${(this / 1099511627776).toStringAsFixed(fractionDigits)}TB";
    } else if (this >= 1073741824) {
      return "${(this / 1073741824).toStringAsFixed(fractionDigits)}GB";
    } else if (this >= 1048576) {
      return "${(this / 1048576).toStringAsFixed(fractionDigits)}MB";
    } else if (this >= 1024) {
      return "${(this / 1024).toStringAsFixed(fractionDigits)}KB";
    }

    return "${this}B";
  }
}
